package src;

import java.util.Scanner;

public class ArrayTester {
    public static void main(String[] args) {
        int[] a=new int[]{
                72,89,65,58,87,91,53,82,71,93,76,68};
        int s=0;
        for (int i = 0; i <a.length ; i++) {

            s=s+a[i];
        }
        System.out.println("学生的平均成绩是："+s/12);

        System.out.println("交换之前成绩排序：");
        for (int num:a){
            System.out.print(num+" ");
        }
        for (int i = 0; i <a.length-1 ; i++) {
            int k=i;
            for (int j = k+1; j <a.length ; j++) {
                if (a[j]>a[k])
                    k=j;
            }
            if (i!=k){
                int temp=a[i];
                a[i]=a[k];
                a[k]=temp;
            }
        }
        System.out.println();
        System.out.println("交换后从大到小成绩排序");
        int counter=0;
        int counter1=0;
        int counter2=0;
        int counter3=0;
        for (int i = 0; i <a.length ; i++) {
            System.out.print(a[i]+" ");

            if (a[i]>=85) counter++;
            if (a[i]>=70 && a[i]<=84) counter1++;
            if (a[i]>=60 && a[i]<=69) counter2++;
            if (a[i]<60) counter3++;
        }System.out.println();
        System.out.println();
        Scanner stdIn=new Scanner(System.in);
        while (true) {
            System.out.println("请从A,B,C,D四个等级中任意输入一个！！！");
            String t = stdIn.next();
            char point = t.charAt(0);
            switch (point) {
                case 'A':
                    System.out.println(counter + "人");
                    break;
                case 'B':
                    System.out.println(counter1 + "人");
                    break;
                case 'C':
                    System.out.println(counter2 + "人");
                    break;
                case 'D':
                    System.out.println(counter3 + "人");
                    break;
                    default:
                        System.out.println("您的输入不正确！！！");break;

            }
        }





    }
}
